package team.tttxs.ct.hibernate.dao;

import java.util.List;
import java.util.Map;

import team.tttxs.ct.hibernate.dao.util.Page;


public interface BaseDao<T> {
	/**
	 * a runtime exception will be thrown if no such domain found
	 */
	T get(String id);
	
	List<T> get(List<String> ids);
	
	/**
	 * if page is null, then return all
	 */
	List<T> get(Map<String, Object> queryOptions, Page page);
	
	/**
	 * a runtime exception will be thrown if no such domain found
	 */
	void save(T obj);
	
	T insert(T obj);
	
	void remove(String id);
	
	/**
	 * partial update, 
	 * revision is used for optimistic lock check if it is present
	 */
	int update(String id, Integer revision, Map<String, Object>updateMap);
	
	long count(Map<String, Object> queryOptions);
	
	List<T> nativeQuery(String sql, List<Object> args);
	
	int nativeNonQuery(String sql, List<Object> args);
	
	void insert(T obj, String collectionName);
	
	List<T> get(Map<String, Object> queryOptions, Page page, String collectionName);
	
	int update(String id, Integer revision, Map<String, Object>updateMap, String collectionName);
	
	void remove(String id, String collectionName);
	
	void save(T obj, String collectionName);
	
}
